package cn.jaye.fabric.controller;

import cn.jaye.fabric.application.ChannelApplicationService;
import cn.jaye.fabric.application.command.channel.ListChannelNamesByPeerCommand;
import cn.jaye.fabric.common.constants.Global;
import cn.jaye.fabric.common.util.ResultUtil;
import cn.jaye.fabric.domain.model.User;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Jaye
 * @create 2018-05-02 11:48
 */
@RestController
@RequestMapping("channel")
public class ChannelController {

    @Autowired
    private ChannelApplicationService channelApplicationService;

    @PostMapping("/name/peer/list")
    public String list(HttpServletRequest request, @RequestBody ListChannelNamesByPeerCommand listChannelNamesByPeerCommand) throws Exception {
        return ResultUtil.success(channelApplicationService.listChannelNames(listChannelNamesByPeerCommand));
    }
    @PostMapping("/list")
    public String list(HttpServletRequest request) throws Exception {
        return ResultUtil.success(channelApplicationService.listAllChannelNames());
    }
}
